package com.java.controller;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.java.pojo.InRoomInfoBean;
import com.java.service.InRoomService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * @function:
 * @CreateTime: 2021/3/16 22:37
 */
@Controller
public class InRoomController {
    @Autowired
    private InRoomService inRoomService;

    /**
     *  入住信息多条件查询
     * @param pageNum
     * @param pageSize
     * @param customerName
     * @param idcard
     * @param phone
     * @param roomnum
     * @param model
     * @return
     */
    @RequestMapping("getInRoomInfo")
    public String getInRoomInfo(@RequestParam(defaultValue = "1")int pageNum,@RequestParam(defaultValue = "5")int pageSize, String customerName, String idcard, String phone,String roomnum, Model model){
        PageHelper.startPage(pageNum, pageSize);
        PageInfo<Map<String, Object>> mapPageInfo = new PageInfo<Map<String, Object>>(inRoomService.getInRoomInfo(customerName, idcard, phone, roomnum));
        model.addAttribute("pageInfo",mapPageInfo);
        return "bill/inroominfo.jsp";
    }
    /**
     * 入住信息添加
     */
    @RequestMapping("addInRoomINfo")
    @ResponseBody
    public boolean addInRoomINfo(InRoomInfoBean inRoomInfoBean){
        return inRoomService.insertInRoomInfo(inRoomInfoBean);
    }
    /**
     * 消费记录查询
     */
    @RequestMapping("getOrderInfo")
    @ResponseBody
    public PageInfo<Map<String, Object>> getOrderInfo(@RequestParam(defaultValue = "1")int pageNum,@RequestParam(defaultValue = "5")int pageSize){
        PageHelper.startPage(pageNum, pageSize);
        PageInfo<Map<String, Object>> orderPageInfo = new PageInfo<Map<String, Object>>(inRoomService.getOrderInfo());
       return orderPageInfo;
    }
}
